package groovy.sample.userguide.closure;

import groovy.lang.Closure;

import java.io.File;

public class ClassHasEachDirMethod {
	public static void eachDir(File self, Closure closure) {
		File[] files = self.listFiles();
		for (File file : files) {
			if (file.isDirectory()) closure.call(file);
			if (file.isFile()) closure.call(file.getName());
		}
	}
}
